package org.jxy.study.rpc.uitl;

import org.jxy.study.rpc.config.RpcFactory;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Proxy;

/**
 * @author : porteryao
 * @description : 描述
 * @date : 2021/3/12 10:37
 */
public class ProxyBeanUtil {

    public static <T> T getProxy(Class<?> rpcInterface) {
        InvocationHandler bean = SpringBeanUtil.getBeanByClass(RpcFactory.class);
        return (T) Proxy
            .newProxyInstance(rpcInterface.getClassLoader(), new Class[]{rpcInterface}, bean);
    }
}
